package com.songlanyun.modules.account.service;

import com.songlanyun.common.drive.IBaseService;
import com.songlanyun.common.enums.GoodsConstant;
import com.songlanyun.common.enums.MemberConstant;
import com.songlanyun.common.streamquery.BaseBatchData;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.modules.account.entity.AccountEntity;
import com.songlanyun.modules.account.entity.UserServiceAreaEntity;
import com.songlanyun.modules.account.model.dto.AccountDTO;
import com.songlanyun.modules.account.model.dto.ImportUserDTO;
import com.songlanyun.modules.account.model.dto.SelectAreaDTO;
import com.songlanyun.modules.account.model.dto.ServiceSystemDTO;
import com.songlanyun.modules.account.model.vo.*;
import com.songlanyun.modules.user.form.MobileForm;
import com.songlanyun.modules.user.form.PasswordForm;
import com.songlanyun.pay.configure.AliPayConfig;
import io.swagger.models.auth.In;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * 会员帐号表（会员的基本信息与关系）
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-02 15:51:10
 */
public interface AccountService extends IBaseService<Long, AccountEntity> {

    Boolean activationUser(Long userId);
    @Override
    PageUtils queryPage(Map<String, Object> params);

    PageUtils queryShopMemberPage(Map<String, Object> params);

    PageUtils queryUserShopRolePage(Map<String, Object> params);

    List<AccountEntity> select(Map<String, Object> params);

    Long saveAccount(AccountEntity yxtAccountEntity, AccountDTO yxtAccountDTO);

    Long saveWxAccount(AccountEntity yxtAccountEntity, AccountDTO yxtAccountDTO);

    void updatePass(AccountEntity account, String password, String newPassword);

    void updateMobile(AccountEntity account, String mobile, String newMobile, String invitationCode);

    Map<String, String> getOpenIdAndSessionKey(Map<String, Object> param);

    String getWxMobile(Map<String, Object> param);

    /**
     * 根据openid查询会员
     *
     * @param openId
     * @return
     */
    AccountEntity getAccountByOpenId(String openId);

    /**
     * 根据手机号查询会员
     * 判断用户是否锁定
     *
     * @param mobile
     * @return
     */
    AccountEntity getByMobile(String mobile);

    /**
     * 根据邀请码查询上级会员信息
     *
     * @param invitationCode
     * @return
     */
    AccountEntity getByCode(String invitationCode);

    /**
     * 微信注册
     *
     * @param accountDTO
     * @param accountM
     * @return
     */
    Long WxRegister(AccountDTO accountDTO, AccountEntity accountM);

    /**
     * 将推荐的所有会员都查询出来 （1、parentPath 2、排除店铺 3、排除上级店铺与自己不一致的）
     *
     * @param
     * @return
     */
    List<Long> getSubordinate(String parentPath, Long subjectionShopId);

    /**
     * 修改这些会员的会员表中的隶属商家
     *
     * @param accountList
     * @param shopId
     */
    void updateByShopId(List<Long> accountList, Long shopId);

    AccountEntity getUserById(Long userId, Boolean tw);

    AccountInfoVO getAllById(Long id, Long shopId);

    /**
     * *会员消费到达升级    -- 提供接口
     *
     * @param userId 会员id
     * @param shopId 会员在此商铺消费的商铺id
     * @param amount 消费金额
     */
    void memberConsumeUpgrade(Long userId, Long shopId, BigDecimal amount);

    /**
     * 会员推荐人数到达升级
     *
     * @param userId 推荐人id
     */
    void memberRecommendedUpgrade(Long userId);

    void updateStatus(Long id, Boolean lock_status);

    void updateOflineShopownerStatus(Long id, Integer oflineShopowner);

    String getMobileByUserId(Long userId);

    /**
     * 查询会员的隶属商家id
     *
     * @param userId
     * @return
     */
    Long getSubjectionShopId(Long userId);

    String getOpenId(Map<String, Object> params);

    String getCodeById(Long id);

    byte[] getWxCode(String scene);

    /**
     * 记录最后一次登录时间
     */
    void lastLoginTime(Long id);

    /**
     * 获取所有上级会员
     *
     * @return
     */
    List<AccountParentVO> getAllParentUser(Long userId);
    List<AccountParentVO> getAllLevelUpParentUser(Long userId);

    /**
     * 获取所有上级会员及其在平台店的等级
     *
     * @return
     */
    List<AccountParentVO> getAllParentUserAndLevel(Long userId, Long shopId);

    AccountVO getAccountInfo(Long userId);

    AccountVO getAccountSubInfo(Long userId, Long shopId);

    List<AccountDownVO> myPartner(Long userId);

    int myPartnerNum(Long userId);

    AccountVO getShopAccountInfo(Long userId, Long shopId);

    AccountAppVO appAccountInfo(Long userId);

    String getQrcodeByCode(String code);

    void saveQrcode(AccountEntity account);

    void batchImport(List<ImportUserDTO> list, Long ptShopId, Long ptUserId);

    List<AccountExportVO> exportList(Map<String, Object> params);

    List<AccountVO> shopMemberExportList(Map<String, Object> params);

    void updateGrade(AccountEntity account, Function<Object, Object> callBack);

    void forgetPass(PasswordForm form);

    void changeMobile(MobileForm form, Long userId);

    AccountEntity disposeCode(String invitationCode);

    AccountEntity platformCode();

    List<Long> getAllMemberId();

    AccountAppVO appInfo(Long userId);

    Integer memberStatistics(Long shopId, Integer type);

    void verifyMobile(String newMobile);

    OperatingCenterVO operatingCenterInfo(Long userId);

    String getWechatOpenIdByCode(String code);

    String getAlipayUserIdByCode(String code);

    CenterSettingVO centerSettingInfo(Long userId, Integer number);

    /**
     * 根据区域类型和区域查询对应用户
     *
     * @param areaType           区域类型
     * @param code               区域对应的code
     * @return
     */
    AccountParentVO loadByArea( MemberConstant.AreaType areaType, String code);


    AliPayConfig getConfig();

    Integer getAllActivatingCount(Long userId);

    List<AccountEntity> getAllActivatingUsers();

    Integer getChildActivatingCount(Long userId);

    AccountAppVO getByShareCode(String invitationCode);

    List<Long> getDownAllUserIds(Long userId);

    void updateAccountAddress(Long userId, String accountAddress);

    List<AccountEntity> getNullAccoutAddressUsers(Integer limit);

    List<HashMap<String,Object>> updateTeamLevel();
    void updateGradeById(List<HashMap<String,Object>> list);

    List<AccountEntity> selectUserAdvList(Integer seeTimesOneDay);

    List<AccountEntity> getUserInviteList(Long userId);



}

